package com.darren.euc.action;
import com.darren.euc.entity.Member;
import com.darren.euc.service.MemberService;
import com.darren.euc.util.PropertyConfigurer;
import com.darren.euc.util.haqi.HaquAPIHandler;
import com.darren.euc.util.haqi.request.AddFaceRequest;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.io.File;

/**
 * Created by Machenike-Pc on 2018/4/2.
 */
@Controller
@RequestMapping("/test")
public class TestController {
    private static final Logger log = Logger.getLogger(TestController.class);

    @Autowired
    private MemberService memberService;
    @RequestMapping(value ="/more")
    public void testInterface(HttpServletRequest request){
        AddFaceRequest addRequest = new AddFaceRequest();
        //request.getAttribute("member");
        String appCode = PropertyConfigurer.getPropertiesStr("haqi.appcode");
        addRequest.setAppCode(appCode);
        addRequest.setUserCode("123");
        Member member = memberService.findByMemberId(2);
        //addRequest.setImgFile();
        addRequest.setUserCode(Integer.toString(member.getId()));
        //addRequest.setImgFile(new File("d:/666.png"));
       // String host = request.getRemoteHost();
       // String path = request.getScheme()+"://"+request.getRemoteHost()+":"+request.getServerPort();
      //  addRequest.setImgUrl(member.getFaceUrl());
        addRequest.setImgUrl("http://p2.ifengimg.com/a/2018_14/7653144ca4d1529_size57_w400_h553.jpg");
        String response = HaquAPIHandler.addFace(addRequest);
        System.out.println(response);
    }
}
